 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" import="servlets.*" %>
<%@ page session="true" import="classes.*" %>
<%@ page session="true" import="beans.*" %>
<%@ page session="true" import="java.sql.ResultSet" %>
<%  	session = request.getSession(true); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%  	
	Noticia noticia  = (Noticia)session.getValue("noticia");
	String url_imagem = ""; 
	String url_video = "";
%>  
<%@page import="java.util.List"%><html class="js" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%  out.print(noticia.getTitulo()); %></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<%@ include file="inc_head.jsp" %>  


</head>
<body>  
<div id="page"> 
  <div id="wrapper"> 
    <div id="header"> <a href="?pg=index"><img src="index_arquivos/logo.png" alt="" id="logo"></a> 
            <h2><a href="Home"></a></h2> 
      <div class="slogan" style="color:#ffffff"></div> 
    </div> 
    <div id="left-col"> 
    
   <%@ include file="inc_menutop.jsp" %>   

      
      <!-- /nav -->  
      <div id="content"> 
        <div class="dbx-box" id="block-block"> 
          <div> 
            <% if (request.getParameter("msg_sucesso") != null) { %> 
            <div id="msg_sucesso"><% out.print(request.getParameter("msg_sucesso")); %></div>
            <% } %>
              <% if (request.getParameter("msg_erro") != null) { %> 
            <div id="msg_erro"><% out.print(request.getParameter("msg_erro")); %></div>
            <% } %> 
            

  

  
                     	
                       	<h1><%  out.print(noticia.getTitulo()); %><img src="css/rating_<% out.print(session.getValue("nota")); %>_mini.gif"></h1>   
							
	    
                        	<%  out.print(noticia.getCorpo()); %><br />
                        	
                        	<form action="VotoAdd" method="post">
                        		<b>Avaliar: </b> <select name="nota">
                        			<option value=""></option>
                        			<option value="0">0</option>
                       				<option value="1">1</option>
                       				<option value="2">2</option>
                       				<option value="3">3</option>
                       				<option value="4">4</option>
                        			<option value="5">5</option> 
                        		</select> 
                        		<input type="submit" name="" value="&raquo;">
                       			<input type="hidden" name="id_noticia" value="<% out.print(noticia.getId()); %>">
                        	</form>  
                        	<br />
                        	<div style="border:1px solid #dadada;background-color:#f3f3f3;padding:5px">
 							<strong>Dados da noticia</strong><br />
 							Publicada em: <%  out.print(noticia.data_ddmmyyyy()); %> por <i><%  AutorDAO autorDAO = new AutorJDBC(); out.print(autorDAO.findById(noticia.getId_autor()).getNome()); %></i><br />
 							<i>Categoria:</i><%  
 							CategoriaDAO categoriaDAO = new CategoriaJDBC();
 							out.print(categoriaDAO.findById(noticia.getId_categoria()).getNome()); %><br />
                        	<% if(noticia.getTags() != "") {%>
                        		 	
                         		 <i>Tags:</i> <%  TagDAO tagDAO = new TagJDBC();out.print(tagDAO.findByIdNoticia(noticia.getId())); %> 
                        		
                        	<% } %> 
 
                        	</div>
                        	<br />  <br /> 


    
					<% 
					NoticiaDAO noticiaDAO = new NoticiaJDBC();
					List<Imagem> imagens = noticiaDAO.findAllImagens(noticia.getId());
					List<Video> videos = noticiaDAO.findAllVideos(noticia.getId());

					
					if((videos != null && videos.size() > 0) || (imagens != null && imagens.size() > 0)) {
						out.print("<h2>Videos e Imagens</h2>");
						for(int j = 0; j < videos.size(); j++) {
							Video video = videos.get(j);
							out.print(video.getHTMLpeq());		
						} 
						for(int j = 0; j < imagens.size(); j++) {
							Imagem imagem = imagens.get(j);
							out.print(imagem.getHTMLpeq());					
						} 						
					
						out.print("     <br /><br /> <div style=\"clear:both\"></div>");
					} 		
					%> 

					
					

			

			<h2>Comentarios</h2>	
			
			<% 
			List<Comentario> comentarios = noticiaDAO.getComentarios(noticia.getId());
			if((comentarios != null && comentarios.size() > 0)) {
			%>
			<ul>
					
				<% 
					for(int m = 0; m < comentarios.size(); m++) {
						Comentario comentario = comentarios.get(m);
						out.print("<li>"+comentario.getCorpo()+"  ("+comentario.data_ddmmyyyy()+")</li>");
					}
				%>
			</ul> 
			
			<% } %>
			
			
			  <form action="ComentariosAdd" method="post">	          
              <p>
               
			    <strong>Adicionar Comentario</strong><br />
			        <strong>
			     <textarea name="corpo" id="corpo" style="width:500px"  rows="5"></textarea>
			      </strong>                </p>

              <br />   
              <p>
	              <span class="botao_comum" style="float:left">
	               <input type="hidden" name="id_noticia" value="<%  out.print(noticia.getId()); %>" />
	            	  <input type="submit" value="Comentar" />
	              </span>           
              </p>
				
				</form>
					
				<br /><br /> <div style="clear:both"></div>	
     

     
		</div> 
        </div> 
      </div> 
      <div id="footer">&nbsp;</div> 
    </div> 
    

   <%@ include file="inc_menu.jsp" %>  



    <hr class="hidden"> 
  </div> 
</div> 
</body>
</html>
